package cn.edu.ujs.coor.repository.relation;

import cn.edu.ujs.coor.model.GroupUserRelation;
import cn.edu.ujs.coor.model.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface GroupUserRelationRepository extends JpaRepository<GroupUserRelation, String>, JpaSpecificationExecutor<GroupUserRelation> {

    /**
     * 根据分组编号查询用户编号
     * @param groupId
     * @return
     */
    @Query(value = "select user_id from coor_group_user where group_id = ?1", nativeQuery = true)
    List<String> findByGroupId (String groupId);

    /**
     * 根据分组编号删除关联
     * @param groupId
     */
    void deleteByGroupId (String groupId);

    /**
     * 根据用户编号删除
     * @param userId
     */
    void deleteByUserId (String userId);
}
